﻿using System;
using System.Web;
using System.Data;

namespace msBsc.WebUi
{
    public partial class wfCustOrderRate : msBsc.Cls.BPCustom
    {
        protected void Page_Load(object sender, EventArgs e)
        { 
            if (!IsPostBack)
            {
                ShowData(this.Request.QueryString.Get("ID"));
            }
        }

        public DataRow drOrder = null;
        private string strOrderId = "";
        private void ShowData(string strId)
        {
            if (string.IsNullOrEmpty(strId))
            {
                this.ToErrPage("当前要评价的订单未找到，请返回重新选择！");
                return;
            }
            using (msBsc.AppLogic.DataAlc.CBizShpOrderForm oCDbAccess = new msBsc.AppLogic.DataAlc.CBizShpOrderForm())
            {
                System.Data.DataSet ds = oCDbAccess.SelectById(strId);
                if (ds.Tables[0].Rows.Count <= 0)
                {
                    this.ToErrPage("当前要评价的订单未找到，请返回重新选择！");
                    return;
                }
                else
                {
                    if (ds.Tables[0].Rows[0]["USER_NME"].ToString().ToUpper() != this.oUserInfo.Operator.ToUpper())
                    {
                        this.ToErrPage("非法的访问，只能评价自己购买的订单！");
                        return;
                    }
                    if (ds.Tables[0].Rows[0]["TRADE_STATUS_TXT"].ToString() != "交易成功")
                    {
                        this.ToErrPage("订单未完成交易，不能评价！");
                        return;
                    }

                    strOrderId = strId;
                    this.ExecJScript("$('#txtId').val('" + strOrderId + "');");
                    drOrder = ds.Tables[0].Rows[0];
                }
            }
        }

        public string GetHeaderNav()
        {
            System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();
            sbHtml.Append(@"
                    <li class=""header-nav-item"">店铺： <a href=""/c_ShopView.htm?ID=" + drOrder["COMM_TENANT_ID"].ToString() + @""" target=""_blank"">" + drOrder["COMM_TENANT_NME"].ToString() + @"</a> </li>
                    <li class=""header-nav-item"">掌柜： <a href=""/c_ErrInfo.htm"" target=""_blank"">" + drOrder["COMM_USER_NME"].ToString() + @"</a> </li>
                    <li class=""header-nav-item""></li>");
            return sbHtml.ToString();
        }

        public string GetRateListView()
        {
            System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();
            using (msBsc.AppLogic.DataAlc.CBizShpOrderRate objlist = new AppLogic.DataAlc.CBizShpOrderRate())
            {
                DataSet dslist = objlist.SelectForRateShowByOrderId(strOrderId);
                for (int i = 0; i < dslist.Tables[0].Rows.Count; i++)
                {
                    DataRow dritem = dslist.Tables[0].Rows[i];

                    string strRateLi = "";
                    if (dritem["BUYER_RATE_NUM"].ToString() == "1")
                    {
                        strRateLi = @"
                    <li class=""good"">
                        <label > 
                            <i class=""icon icon-rank icon-good""></i><span class=""label-hidden"">好评</span>
                        </label>
                        <span class=""rate-score rate-score-good"">卖家
                            <br>
                            +1分</span> </li>";
                    }
                    else if (dritem["BUYER_RATE_NUM"].ToString() == "0")
                    {
                        strRateLi = @"
                    <li class=""normal"">
                        <label for=""rate-normal-" + dritem["ORDER_LIST_ID"].ToString() + @""">
                            <i class=""icon icon-rank icon-normal""></i><span class=""label-hidden"">中评</span>
                        </label>
                        <span class=""rate-score rate-score-normal"">卖家
                            <br>
                            不加分</span> </li>";
                    }
                    else if (dritem["BUYER_RATE_NUM"].ToString() == "-1")
                    {
                        strRateLi = @"
                    <li class=""bad"">
                        <label for=""rate-bad-" + dritem["ORDER_LIST_ID"].ToString() + @""">
                            <i class=""icon icon-rank icon-bad""></i><span class=""label-hidden"">差评</span>
                        </label>
                        <span class=""rate-score rate-score-bad"">卖家
                            <br>
                            -1分</span> </li>";
                    }

                    string strImgli = "";
                    if (dritem["GOODS_IMG_URL1"].ToString() != "")
                    {
                        strImgli += @"<li><img src=""" + dritem["GOODS_IMG_URL1"].ToString() + @"""><b class=""tm-photos-arrow""></b></li>";
                    }
                    if (dritem["GOODS_IMG_URL2"].ToString() != "")
                    {
                        strImgli += @"<li><img src=""" + dritem["GOODS_IMG_URL2"].ToString() + @"""><b class=""tm-photos-arrow""></b></li>";
                    }
                    if (dritem["GOODS_IMG_URL3"].ToString() != "")
                    {
                        strImgli += @"<li><img src=""" + dritem["GOODS_IMG_URL3"].ToString() + @"""><b class=""tm-photos-arrow""></b></li>";
                    }
                    if (dritem["GOODS_IMG_URL4"].ToString() != "")
                    {
                        strImgli += @"<li><img src=""" + dritem["GOODS_IMG_URL4"].ToString() + @"""><b class=""tm-photos-arrow""></b></li>";
                    }
                    if (dritem["GOODS_IMG_URL5"].ToString() != "")
                    {
                        strImgli += @"<li><img src=""" + dritem["GOODS_IMG_URL5"].ToString() + @"""><b class=""tm-photos-arrow""></b></li>";
                    }
                    if (dritem["GOODS_IMG_URL1"].ToString() != "")
                    {
                        strImgli = @"
                                <div class=""tm-m-photos"">
                                    <ul class=""tm-m-photos-thumb"">
                                        " + strImgli + @"
                                    </ul>
                                    <div class=""tm-m-photo-viewer"" style=""width: 250px; height: 250px; display: none;"">
                                        <img src=""data:image/png;base64,"" style=""width: 250px; max-height: 250px; ""></div> 
                                </div>";
                    }

                    sbHtml.Append(@"
        <div class=""rate-grid"">
        <table>
            <tbody id=""ratetbody"">



                <tr>
                    <td class=""col-author"">

    <div class=""item-rate-info"">
        <div class=""item-detail"">
            <a href=""/c_GoodsView.htm?ID=" + dritem["GOODS_ID"].ToString() + @"""
                target=""_blank"" class=""item-d-img"">
                <img src=""" + dritem["IMG_URL"].ToString() + @""" style=""width:130px;height:130px;"">
            </a>
            <div class=""item-title"">
                <a href=""/c_GoodsView.htm?ID=" + dritem["GOODS_ID"].ToString() + @"""
                    target=""_blank"" title=""" + dritem["GOODS_NME"].ToString() + @""">" + dritem["GOODS_NME"].ToString() + @"</a>
            </div>
        </div>
    </div>
                    </td>
                    <td class=""tm-col-master"">
                        <div class=""tm-rate-premiere"">
                            <div class=""tm-rate-tag"">
                                <div class=""tm-rate-title"">
                                    初次评价:</div>
                                <div class=""tm-rate-date"">
                                    " + dritem["BUYER_RATE_DT1"].ToString() + @"</div>
                            </div>
                            <div class=""tm-rate-content"">
                                <div class=""tm-rate-fulltxt"">
                                    " + dritem["BUYER_RATE_DESC1"].ToString() + @"</div>
                                " + strImgli + @"
                            </div>
                            <div class=""tm-rate-reply"">
                                <div class=""tm-rate-fulltxt"">
                                    " + (dritem["SELLER_REPLY1"].ToString() != string.Empty ? "解释：" + dritem["SELLER_REPLY1"].ToString() : "") + @"</div>
                            </div>
                        </div>
                        "+(dritem["BUYER_RATE_DESC2"].ToString() != string.Empty ? @"
                        <div class=""tm-rate-append"">
                            <div class=""tm-rate-tag"">
                                <div class=""tm-rate-title"">
                                    <span class=""tm-rate-daydiff"">追加：</span></div>
                                <div class=""tm-rate-date"">
                                </div>
                            </div>
                            <div class=""tm-rate-content"">
                                <div class=""tm-rate-fulltxt"">
                                    " + dritem["BUYER_RATE_DESC2"].ToString() + @"</div>
                            </div>
                            <s></s>
                        </div>" :"")+@"
                    </td>
                    <td class=""col-meta"">
                        <div class=""rate-sku"">
                            <p ></p>
                        </div>
                        <div class=""rate-user-profile"">
                            <p title="""">
                            </p>
                        </div>
                    </td>
                </tr>




            </tbody>
        </table>
    </div>
");
                }
            }
            return sbHtml.ToString();
        }
          
        public string GetRateList()
        {
            if (drOrder["BUYER_RATE_SID"].ToString() == "1" || drOrder["BUYER_RATE_SID"].ToString() == "2")
            {
                return GetRateListView();
            }
            System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();
            using (msBsc.AppLogic.DataAlc.CBizShpOrderFormList objlist = new AppLogic.DataAlc.CBizShpOrderFormList())
            {
                DataSet dslist = objlist.SelectByOrderId(strOrderId);
                for (int i = 0; i < dslist.Tables[0].Rows.Count; i++)
                {
                    DataRow dritem = dslist.Tables[0].Rows[i];
                    sbHtml.Append(@"
<li data-id=""" + dritem["ORDER_LIST_ID"].ToString() + @""" class=""rate-box " + (dslist.Tables[0].Rows.Count - 1 == i ? "rate-box-last" : "") + @"""> 
    <div class=""item-rate-info"">
        <div class=""item-detail"">
            <a href=""/c_GoodsView.htm?ID=" + dritem["GOODS_ID"].ToString() + @"""
                target=""_blank"" class=""item-d-img"">
                <img src=""" + dritem["IMG_URL"].ToString() + @""" style=""width:130px;height:130px;"">
            </a>
            <div class=""item-title"">
                <a href=""/c_GoodsView.htm?ID=" + dritem["GOODS_ID"].ToString() + @"""
                    target=""_blank"" title=""" + dritem["GOODS_NME"].ToString() + @""">" + dritem["GOODS_NME"].ToString() + @"</a>
            </div>
        </div>
    </div>
    <div class=""item-rate-main"">
        <div class=""item-rate-act"">
            <div class=""rate-control"">
                <ul>
                    <li class=""good"">
                        <label for=""rate-good-" + dritem["ORDER_LIST_ID"].ToString() + @""">
                            <input id=""rate-good-" + dritem["ORDER_LIST_ID"].ToString() + @""" name=""rates" + dritem["ORDER_LIST_ID"].ToString() + @""" type=""radio"" value=""1""
                                class=""good-rate"">
                            <i class=""icon icon-rank icon-good""></i><span class=""label-hidden"">好评</span>
                        </label>
                        <span class=""rate-score rate-score-good"">卖家
                            <br>
                            +1分</span> </li>
                    <li class=""normal"">
                        <label for=""rate-normal-" + dritem["ORDER_LIST_ID"].ToString() + @""">
                            <input id=""rate-normal-" + dritem["ORDER_LIST_ID"].ToString() + @""" name=""rates" + dritem["ORDER_LIST_ID"].ToString() + @""" type=""radio""
                                value=""0"" class=""noraml-rate"">
                            <i class=""icon icon-rank icon-normal""></i><span class=""label-hidden"">中评</span>
                        </label>
                        <span class=""rate-score rate-score-normal"">卖家
                            <br>
                            不加分</span> </li>
                    <li class=""bad"">
                        <label for=""rate-bad-" + dritem["ORDER_LIST_ID"].ToString() + @""">
                            <input id=""rate-bad-" + dritem["ORDER_LIST_ID"].ToString() + @""" name=""rates" + dritem["ORDER_LIST_ID"].ToString() + @""" type=""radio"" value=""-1""
                                class=""bad-rate"">
                            <i class=""icon icon-rank icon-bad""></i><span class=""label-hidden"">差评</span>
                        </label>
                        <span class=""rate-score rate-score-bad"">卖家
                            <br>
                            -1分</span> </li>
                </ul>
            </div>
        </div>
        <div class=""rate-msg-box"">
            <div class=""bd"">
                <div class=""textinput"">
                    <textarea name=""rateContents" + dritem["ORDER_LIST_ID"].ToString() + @""" maxlength="""" 
                        class=""rate-msg""></textarea>
                    <div class=""text-counter"">
                        <strong class=""r-t-counter"">500</strong>字</div>
                </div>
            </div>
            <div class=""ft"">
                <div class=""share-box""> 
                </div>
                <div class=""photo-uploader"">
                    <a class=""upload-btn btn-chrome"" href=""javascript:void(0);return false;"" >
                        <i class=""icon-img-upload""></i>晒照片<div class=""file-input-wrapper"" style=""overflow: hidden;"">
                            </div>
                        </a> 
                    <ul class=""upload-queue"">
                    </ul>
                    <span class=""upload-msg"">限5张，图片上双击可删除</span>
                </div>
            </div>
        </div> 
    </div>
</li>");
                }
            }
            this.ExecJScript("$('.submit-btn').show();");
            return sbHtml.ToString();
        }

        public string GetShopSvcLiView()
        {
            System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();

            sbHtml.Append(@"
                    <li id=""liDESC_MATCH_RATE"">
                        <label>
                            宝贝与描述相符</label> <span class=""ks-simplestar selected-rate setview"">
                                <img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""1"" title=""很不满意，差得太离谱，与卖家描述的严重不符，非常不满""><img
                                    src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""2"" title=""不满意，部分有破损，与卖家描述的不符，不满意""><img
                                        src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""3"" title=""一般，质量一般，没有卖家描述的那么好""><img
                                            src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""4"" title=""满意，质量不错，与卖家描述的基本一致，还是挺满意的""><img
                                                src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""5"" title=""很满意，质量非常好，与卖家描述的完全一致，非常满意""></span>
                        <span class=""ks-ss-tips""></span></li>
                    <li id=""liSERVICE_RATE"">
                        <label>
                            卖家的服务态度</label> <span class=""ks-simplestar selected-rate setview"">
                            <img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""1"" title=""很不满意，卖家态度很差，还骂人、说脏话，简直不把顾客当回事""><img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""2"" title=""不满意，卖家有点不耐烦，承诺的服务也兑现不了""><img
                                src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""3"" title=""一般，卖家回复问题很慢，态度一般，谈不上沟通顺畅""><img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""4"" title=""满意，卖家服务挺好的，沟通挺顺畅的，总体满意""><img
                                    src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""5"" title=""很满意，卖家的服务太棒了，考虑非常周到，完全超出期望值""></span><span
                                        class=""ks-ss-tips""></span> </li>
                    <li id=""liSEND_SPEED"">
                        <label>
                            卖家发货的速度</label> <span class=""ks-simplestar selected-rate setview"">
                            <img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""1"" title=""很不满意，再三提醒下，卖家才发货，耽误我的时间，包装也很马虎""><img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""2"" title=""不满意，卖家发货有点慢的，催了几次终于发货了""><img
                                src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""3"" title=""一般，卖家发货速度一般，提醒后才发货的""><img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""4"" title=""满意，卖家发货挺及时的，运费收取很合理""><img
                                    src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""5"" title=""很满意，卖家发货速度非常快，包装非常仔细、严实""></span><span
                                        class=""ks-ss-tips""></span> </li> ");
            this.ExecJScript("setsimplestar('liDESC_MATCH_RATE','" + drOrder["DESC_MATCH_RATE"].ToString() + "');");
            this.ExecJScript("setsimplestar('liSERVICE_RATE','" + drOrder["SERVICE_RATE"].ToString() + "');");
            this.ExecJScript("setsimplestar('liSEND_SPEED','" + drOrder["SEND_SPEED"].ToString() + "');");
            return sbHtml.ToString();
        }

        public string GetShopSvcLi()
        {
            if (drOrder["BUYER_RATE_SID"].ToString() == "1" || drOrder["BUYER_RATE_SID"].ToString() == "2")
            {
                return GetShopSvcLiView();
            }
            System.Text.StringBuilder sbHtml = new System.Text.StringBuilder();

            sbHtml.Append(@"
                    <li id=""liDESC_MATCH_RATE"">
                        <label>
                            宝贝与描述相符</label> <span class=""ks-simplestar"">
                                <img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""1"" title=""很不满意，差得太离谱，与卖家描述的严重不符，非常不满""><img
                                    src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""2"" title=""不满意，部分有破损，与卖家描述的不符，不满意""><img
                                        src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""3"" title=""一般，质量一般，没有卖家描述的那么好""><img
                                            src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""4"" title=""满意，质量不错，与卖家描述的基本一致，还是挺满意的""><img
                                                src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""5"" title=""很满意，质量非常好，与卖家描述的完全一致，非常满意""></span>
                        <span class=""ks-ss-tips""></span></li>
                    <li id=""liSERVICE_RATE"">
                        <label>
                            卖家的服务态度</label> <span class=""ks-simplestar"">
                            <img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""1"" title=""很不满意，卖家态度很差，还骂人、说脏话，简直不把顾客当回事""><img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""2"" title=""不满意，卖家有点不耐烦，承诺的服务也兑现不了""><img
                                src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""3"" title=""一般，卖家回复问题很慢，态度一般，谈不上沟通顺畅""><img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""4"" title=""满意，卖家服务挺好的，沟通挺顺畅的，总体满意""><img
                                    src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""5"" title=""很满意，卖家的服务太棒了，考虑非常周到，完全超出期望值""></span><span
                                        class=""ks-ss-tips""></span> </li>
                    <li id=""liSEND_SPEED"">
                        <label>
                            卖家发货的速度</label> <span class=""ks-simplestar"">
                            <img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""1"" title=""很不满意，再三提醒下，卖家才发货，耽误我的时间，包装也很马虎""><img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""2"" title=""不满意，卖家发货有点慢的，催了几次终于发货了""><img
                                src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""3"" title=""一般，卖家发货速度一般，提醒后才发货的""><img src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""4"" title=""满意，卖家发货挺及时的，运费收取很合理""><img
                                    src=""/themes/Style1/Image/ratenotsel.png"" rate-num=""5"" title=""很满意，卖家发货速度非常快，包装非常仔细、严实""></span><span
                                        class=""ks-ss-tips""></span> </li> ");
            return sbHtml.ToString();
        }

        private void doSaveOrder()
        {
            System.Transactions.TransactionOptions transactionOption = new System.Transactions.TransactionOptions();
            transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
            transactionOption.Timeout = new TimeSpan(0, 10, 0);
            using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOption))
            {
                using (msBsc.AppLogic.DataAlc.CBizShpOrderForm objorder = new AppLogic.DataAlc.CBizShpOrderForm())
                {
                    DataSet ds = objorder.SelectById(this.GetParamHtValue("ID"));
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["BUYER_RATE_SID"].ToString() != "0")
                        {
                            throw new Exception("当前订单不在可评价状态！");
                        } 
                    }

                    using (msBsc.AppLogic.DataAlc.CBizShpOrderRate objrate = new AppLogic.DataAlc.CBizShpOrderRate())
                    {
                        DataSet dslist = objrate.SelectByOrderId(this.GetParamHtValue("ID"));
                        if (dslist.Tables[0].Rows.Count <= 0)
                        {
                            objorder.AddOrderRate(this.GetParamHtValue("ID"));
                            dslist = objrate.SelectByOrderId(this.GetParamHtValue("ID"));
                        }
                        for (int i = dslist.Tables[0].Rows.Count - 1; i >= 0; i--)
                        {
                            DataRow[] arrRowtm1 = dslist.Tables[0].Select("ORDER_LIST_ID='" + this.GetParamHtValue("ORDER_LIST_ID_" + i.ToString()) + "'");
                            if (arrRowtm1.Length > 0)
                            {
                                arrRowtm1[0]["BUYER_RATE_NUM"] = this.GetParamHtValue("BUYER_RATE_NUM_" + i.ToString());
                                arrRowtm1[0]["BUYER_RATE_DESC1"] = this.GetParamHtValue("BUYER_RATE_DESC1_" + i.ToString());
                                arrRowtm1[0]["BUYER_RATE_DT1"] = System.DateTime.Now;
                                using (msBsc.AppLogic.DataAlc.CBizSysFile oCBizSysFile = new msBsc.AppLogic.DataAlc.CBizSysFile())
                                {
                                    arrRowtm1[0]["GOODS_IMG_URL1"] = oCBizSysFile.SaveImgToServer(""
                                                , arrRowtm1[0]["ORDER_LIST_ID"].ToString()
                                                , "0"
                                                , "BUYER_RATE"
                                                , ""
                                                , this.GetParamHtValue("GOODS_IMG_URL_" + i + "_0")
                                                , ""
                                                , true);
                                    arrRowtm1[0]["GOODS_IMG_URL2"] = oCBizSysFile.SaveImgToServer(""
                                                , arrRowtm1[0]["ORDER_LIST_ID"].ToString()
                                                , "0"
                                                , "BUYER_RATE"
                                                , ""
                                                , this.GetParamHtValue("GOODS_IMG_URL_" + i + "_1")
                                                , ""
                                                , true);
                                    arrRowtm1[0]["GOODS_IMG_URL3"] = oCBizSysFile.SaveImgToServer(""
                                                , arrRowtm1[0]["ORDER_LIST_ID"].ToString()
                                                , "0"
                                                , "BUYER_RATE"
                                                , ""
                                                , this.GetParamHtValue("GOODS_IMG_URL_" + i + "_2")
                                                , ""
                                                , true);
                                    arrRowtm1[0]["GOODS_IMG_URL4"] = oCBizSysFile.SaveImgToServer(""
                                                , arrRowtm1[0]["ORDER_LIST_ID"].ToString()
                                                , "0"
                                                , "BUYER_RATE"
                                                , ""
                                                , this.GetParamHtValue("GOODS_IMG_URL_" + i + "_3")
                                                , ""
                                                , true);
                                    arrRowtm1[0]["GOODS_IMG_URL5"] = oCBizSysFile.SaveImgToServer(""
                                                , arrRowtm1[0]["ORDER_LIST_ID"].ToString()
                                                , "0"
                                                , "BUYER_RATE"
                                                , ""
                                                , this.GetParamHtValue("GOODS_IMG_URL_" + i + "_4")
                                                , ""
                                                , true); 
                                }
                            }
                            else
                            {
                                throw new Exception("请仔细检查是否正确进行了评价");
                            }
                        }
                        objrate.Update(dslist);
                    }
                    if (ds.Tables[0].Rows.Count > 0)
                    { 
                        ds.Tables[0].Rows[0]["DESC_MATCH_RATE"] = this.GetParamHtValue("DESC_MATCH_RATE");
                        ds.Tables[0].Rows[0]["SERVICE_RATE"] = this.GetParamHtValue("SERVICE_RATE");
                        ds.Tables[0].Rows[0]["SEND_SPEED"] = this.GetParamHtValue("SEND_SPEED");
                        ds.Tables[0].Rows[0]["BUYER_RATE_SID"] = "1";
                        objorder.Update(ds);
                    }
                }
                ts.Complete();
                //                this.ExecJScript("layer.msg('已成功提交订单！',1,{type:1,shade:false});");
                this.ExecJScript("window.location.reload(true);");
            }
            //int iOrderSum = int.Parse(this.GetPostHtValue("ORDER_COUNT") == string.Empty ? "0" : this.GetPostHtValue("ORDER_COUNT"));
//            if (iOrderSum <= 0)
//            {
//                Alert("未选择商品！");
//                return;
//            }
//            string strRecerptId = this.GetPostHtValue("RECE_ADDRESS_ID");
//            if (strRecerptId == string.Empty)
//            {
//                Alert("未选择收货地址！");
//                return;
//            }


//            using (msBsc.AppLogic.DataAlc.CBizShpOrderForm odataobj = new AppLogic.DataAlc.CBizShpOrderForm())
//            {
//                DataSet dsAddr = odataobj.DataObj.QueryBySQL("SELECT * FROM SHP_CUSTOMER_RECEIPT WHERE RECE_ADDRESS_ID='" + strRecerptId + "' AND USER_NME='" + this.oUserInfo.Operator + "'");
//                if (dsAddr.Tables[0].Rows.Count <= 0)
//                {
//                    Alert("未正确选择收货地址！");
//                    return;
//                }
//                DataSet ds = new msBsc.Xsd.DataTds.CDmShpOrderForm();
//                DataSet dsItem = new msBsc.Xsd.DataTds.CDmShpOrderFormList();
//                string strOrderId = "";
//                for (int i = 0; i < iOrderSum; i++)
//                {
//                    DataRow drnew = ds.Tables[0].NewRow();
//                    drnew["ORDER_FORM_ID"] = odataobj.DataObj.NewID();
//                    drnew["USER_NME"] = this.oUserInfo.Operator;
//                    drnew["ORDER_FORM_NO"] = msBsc.AppLogic.Cfg.ApplicationConst.Const.GeneratelongId().ToString();
//                    drnew["COMM_TENANT_ID"] = this.GetPostHtValue("COMM_TENANT_ID_" + i.ToString());
//                    DataSet dsDealer = odataobj.DataObj.QueryBySQL("SELECT COMM_TENANT_NME,USER_NME FROM SHP_COMMERCIAL_TENANT_INFO WHERE COMM_TENANT_ID='" + drnew["COMM_TENANT_ID"].ToString() + "' ");
//                    if (dsDealer.Tables[0].Rows.Count <= 0)
//                    {
//                        Alert("传入的参数错误，商家信息未找到！");
//                        return;
//                    }
//                    if (dsDealer.Tables[0].Rows[0]["USER_NME"].ToString().ToUpper() == this.oUserInfo.Operator.ToUpper())
//                    {
//                        Alert("不能自己购买自己的商品！");
//                        return;
//                    }

//                    drnew["COMM_TENANT_NME"] = dsDealer.Tables[0].Rows[0]["COMM_TENANT_NME"];
//                    drnew["COMM_USER_NME"] = dsDealer.Tables[0].Rows[0]["USER_NME"];


//                    drnew["TO_PROVINCE_ID"] = dsAddr.Tables[0].Rows[0]["PROVINCE_ID"];
//                    drnew["TO_CITY_ID"] = dsAddr.Tables[0].Rows[0]["CITY_ID"];
//                    drnew["TO_AREA_ID"] = dsAddr.Tables[0].Rows[0]["AREA_ID"];
//                    drnew["TO_ZONE_DESC"] = dsAddr.Tables[0].Rows[0]["ZONE_DESC"];
//                    drnew["TO_STREET_ADDRESS"] = dsAddr.Tables[0].Rows[0]["STREET_ADDRESS"];
//                    drnew["TO_ZIP_CODE"] = dsAddr.Tables[0].Rows[0]["ZIP_CODE"];
//                    drnew["TO_RECEIPT_NME"] = dsAddr.Tables[0].Rows[0]["RECEIPT_NME"];
//                    drnew["TO_PHONE_NO"] = dsAddr.Tables[0].Rows[0]["PHONE_NO"];
//                    if (dsAddr.Tables[0].Rows[0]["LANDLINE_NO"].ToString() != string.Empty)
//                    {
//                        drnew["TO_LANDLINE_NO"] = dsAddr.Tables[0].Rows[0]["AREA_CODE"].ToString() + "-" + dsAddr.Tables[0].Rows[0]["LANDLINE_NO"].ToString() + (dsAddr.Tables[0].Rows[0]["EXTENSION_NO"].ToString() != string.Empty ? "-" + dsAddr.Tables[0].Rows[0]["EXTENSION_NO"].ToString() : "");
//                    }
//                    else
//                    {
//                        drnew["TO_LANDLINE_NO"] = "";
//                    }
//                    drnew["TO_RECEIPT_NME"] = dsAddr.Tables[0].Rows[0]["RECEIPT_NME"];
//                    drnew["DELIVER_TYPE_CID"] = "普通快递";

//                    drnew["BUY_MEMO"] = this.GetPostHtValue("BUY_MEMO_" + i.ToString());

//                    int iItemSum = int.Parse(this.GetPostHtValue("ORDER_ITEM_COUNT_" + i.ToString()) == string.Empty ? "0" : this.GetPostHtValue("ORDER_ITEM_COUNT_" + i.ToString()));
//                    //string strGdIds = "";
//                    string strNormsIds = "";
//                    for (int r = 0; r < iItemSum; r++)
//                    {
//                        //strGdIds += strGdIds == string.Empty ? this.GetPostHtValue("GOODS_ID_" + i.ToString() + "_" + r.ToString()) : "','" + this.GetPostHtValue("GOODS_ID_" + i.ToString() + "_" + r.ToString());
//                        strNormsIds += strNormsIds == string.Empty ? this.GetPostHtValue("PUB_NORMS_ID_" + i.ToString() + "_" + r.ToString()) : "','" + this.GetPostHtValue("PUB_NORMS_ID_" + i.ToString() + "_" + r.ToString());
//                    }

//                    //DataSet dsGdList = odataobj.DataObj.QueryBySQL("SELECT GOODS_ID,GOODS_NME FROM SHP_GOODS_INFO WHERE GOODS_ID IN ('" + strGdIds + "') ");
//                    DataSet dsNmList = odataobj.DataObj.QueryBySQL(@"
//    SELECT 
//    A.GOODS_ID
//    ,A.GOODS_NME
//    ,I.IMG_URL
//    ,NORMS_DESC=(CASE WHEN B.PUB_NORMS_NME1<>'' THEN  ' '+(CASE WHEN ISNULL(D.NORMS_NME1,'')<>'' THEN D.NORMS_NME1 ELSE '分类' END) + ':'+ B.PUB_NORMS_NME1 ELSE '' END)
//			    + (CASE WHEN B.PUB_NORMS_NME2<>'' THEN  ','+(CASE WHEN ISNULL(D.NORMS_NME2,'')<>'' THEN D.NORMS_NME2 ELSE '型号' END) + ':'+ B.PUB_NORMS_NME2 ELSE '' END)+'  '
//    ,B.GOODS_STRIKE_PRICE
//    ,A.FREIGHT
//    ,B.PUB_NORMS_ID
//    FROM SHP_GOODS_NORMS_PUBLIC B
//    LEFT OUTER JOIN SHP_GOODS_INFO A ON A.GOODS_ID=B.GOODS_ID
//    LEFT OUTER JOIN SHP_GOODS_TYPE_LEVEL_THREE D ON A.LEVEL_THREE_ID=D.LEVEL_THREE_ID
//    LEFT OUTER JOIN SHP_GOODS_IMG I ON A.GOODS_ID=I.GOODS_ID AND I.SEQ_NUM=0
//    WHERE B.PUB_NORMS_ID IN ('" + strNormsIds + @"')");
//                    decimal decTotal = 0, decAmt = 0, decYf = 0;
//                    for (int r = 0; r < iItemSum; r++)
//                    {
//                        string strGoodsId = this.GetPostHtValue("GOODS_ID_" + i.ToString() + "_" + r.ToString());
//                        DataRow[] arrrowtem1 = dsNmList.Tables[0].Select("GOODS_ID='" + strGoodsId + "'");
//                        if (arrrowtem1.Length <= 0)
//                        {
//                            continue;
//                        }
//                        int iGoodsQty = int.Parse(this.GetPostHtValue("GOODS_QTY_" + i.ToString() + "_" + r.ToString()) == string.Empty ? "1" : this.GetPostHtValue("GOODS_QTY_" + i.ToString() + "_" + r.ToString()));
//                        DataRow dritem = dsItem.Tables[0].NewRow();
//                        dritem["ORDER_LIST_ID"] = odataobj.DataObj.NewID();
//                        dritem["ORDER_FORM_ID"] = drnew["ORDER_FORM_ID"];
//                        dritem["SEQ_NUM"] = r;
//                        dritem["GOODS_ID"] = strGoodsId;
//                        dritem["GOODS_NME"] = arrrowtem1[0]["GOODS_NME"];
//                        dritem["IMG_URL"] = arrrowtem1[0]["IMG_URL"];
//                        dritem["PUB_NORMS_ID"] = arrrowtem1[0]["PUB_NORMS_ID"];
//                        dritem["NORMS_DESC"] = arrrowtem1[0]["NORMS_DESC"].ToString().Substring(1);
//                        dritem["GOODS_QTY"] = iGoodsQty;
//                        dritem["GOODS_STRIKE_PRICE"] = arrrowtem1[0]["GOODS_STRIKE_PRICE"];
//                        decAmt += decimal.Parse(dritem["GOODS_STRIKE_PRICE"].ToString() == string.Empty ? "0.00" : dritem["GOODS_STRIKE_PRICE"].ToString()) * iGoodsQty;
//                        decYf += decimal.Parse(arrrowtem1[0]["FREIGHT"].ToString() == string.Empty ? "0.00" : arrrowtem1[0]["FREIGHT"].ToString());
//                        dsItem.Tables[0].Rows.Add(dritem);
//                    }
//                    decTotal += (decAmt + decYf);
//                    drnew["GOODS_AMT"] = decAmt;
//                    drnew["LOGISTICS_AMT"] = decYf;
//                    drnew["DISCOUNT_AMT"] = 0M;
//                    drnew["PAYABLE_AMT"] = decTotal;
//                    drnew["PAID_AMT"] = 0M;
//                    drnew["REVIEW_STATUS_TXT"] = "";
//                    drnew["TRADE_STATUS_TXT"] = "等待买家付款";
//                    drnew["AFTER_SVC_STATUS_TXT"] = "";
//                    ds.Tables[0].Rows.Add(drnew);

//                    strOrderId += strOrderId == string.Empty ? drnew["ORDER_FORM_ID"].ToString() : "," + drnew["ORDER_FORM_ID"].ToString();
//                }

//                System.Transactions.TransactionOptions transactionOption = new System.Transactions.TransactionOptions();
//                transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted;
//                transactionOption.Timeout = new TimeSpan(0, 10, 0);
//                using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope(System.Transactions.TransactionScopeOption.Required, transactionOption))
//                {
//                    odataobj.Update(ds);
//                    using (msBsc.AppLogic.DataAlc.CBizShpOrderFormList objItem = new AppLogic.DataAlc.CBizShpOrderFormList())
//                    {
//                        objItem.Update(dsItem);
//                    }
//                    //using (msBsc.AppLogic.DataAlc.CBizSysUser ouser = new AppLogic.DataAlc.CBizSysUser())
//                    //{
//                    //    ouser.UpdateOrderStatistic(this.oUserInfo.Operator);
//                    //}

//                    ts.Complete();
//                }
//                this.ExecJScript("layer.msg('已成功提交订单！',1,{type:1,shade:false});");
//                this.ExecJScript("window.location.href = '/c_PayCashier.htm?ID=" + strOrderId + "';");
//            }
        }

        public override void DoAction()
        {
            //if (this.strAction == "updateaddress")
            //{ 
            //    this.ExecJScript("$('#address-list').html('" + msBsc.AppLogic.Cfg.HttpTools.stringToJson(GetPriceHtml(GetParamHtValue("SEL_ID"))) + "');");
            //    this.ExecJScript("updateorderaddr();");
            //}
            //else 
            if (this.strAction == "dosaverate")
            {
                doSaveOrder();
            }
        }
    }
}